<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
    <!--
    .style1 {
        font-size: 24px;
        font-weight: bold;
    }
    -->
</style>
<script src="<?=PATH?>/soanthao/fckeditor.js"></script>
<script>
    onload=function()
    {
        a=new FCKeditor('motasp');
        a.BasePath="<?=PATH?>/soanthao/";
        a.Width="600";
        a.Height="300";
        a.ReplaceTextarea();
    }
</script>
<script>
    function OpenWindow(theURL,winName,features)
    {
        window.open(theURL,winName,features);
    }
</script>
<script>
    function fsanphamsua()
    {
        re=/^ *$/;
        with(frmsuasanpham)
        {
            if(re.test(tensp.value))
            {
                alert("Cần điền tên sản phẩm");
                tensp.value="";
                tensp.focus();
                return false;
            }
            if(re.test(giasp.value))
            {
                alert("Cần điền giá sản phẩm");
                giasp.value="";
                giasp.focus();
                return false;
            }
            if(isNaN(giasp.value)==true)
            {
                alert("Giá sản phẩm phải là một số dương");
                giasp.select();
                return false;
            }
            if(hangsx.selectedIndex==0)
            {
                alert("Cần chọn một hãng sản xuất");
                hangsx.focus();
                return false;
            }
            if(loaisp.selectedIndex==0)
            {
                alert("Cần chọn một loại sản phẩm");
                loaisp.focus();
                return false;
            }

        }
    }
</script>

<?

?>

<?
foreach($this->listpro as $pro)
{
?>
<div class="Main_Header" align="center">Chi tiết sản phẩm: <?=$pro->pname?></div>
<form enctype="multipart/form-data" name="frmsuasanpham" method="post" action="">
    <table width="100%" border="1" align="center" cellpadding="5" cellspacing="0">
        <tr>
            <td width="24%" align="right">T&ecirc;n sa&#777;n ph&acirc;&#777;m: </td>
            <td colspan="2" align="left"><label>
                <input name="tensp" type="text" id="tensp" value="<?=$pro->pname?>" size="60">
            </label></td>
        </tr>
        <tr>
            <td rowspan="2" align="right">A&#777;nh sa&#777;n ph&acirc;&#777;m:  </td>
            <td style="border-bottom:#FFFFFF" width="23%" align="center" valign="top">A&#777;nh hi&ecirc;&#803;n ta&#803;i:<br />
                <br /></td>
            <td width="53%" rowspan="2" align="center" valign="top">Ta&#777;i a&#777;nh m&#417;&#769;i: <br />
                <?
                $data ="../media/images/products/";
                $max_size = "10000000";
                $max_file ="1";
                $file_name=time().'_';
                ?>
            <p>Ch&#7885;n  &#7843;nh &#273;&#7875; upload:
                <input type='file' name='f1' onchange="frmsuasanpham.upload.disabled=false;" />
                <input type='submit' name='upload' value='Upload' style='height:30px; width:80px;' onclick="return fhinhanhthem();" disabled="disabled" />
                <br />
                <?
                if($_REQUEST["upload"]=="Upload")
                {
                    $a = $_FILES["f1"]["tmp_name"];
                    $b = $_FILES["f1"]["name"];
                    $d = $_FILES["f1"]["size"];
                    $c = substr($b,strlen($b)-3,3);
                    if($d>$max_size)
                    {
                        echo("Dung l&#432;&#7907;ng gi&#7899;i h&#7841;n là $max_size KB. File <b>{$b}</b> &#273;ã v&#432;&#7907;t quá gi&#7899;i h&#7841;n cho phép <br>");
                    }
                    else
                    {
                        if($c=="jpg"||$c=="jpeg"||$c=="gif"||$c=="bmp"||$c=="png")
                        {
                            $tenfile = $file_name.$b;
                            move_uploaded_file($a,$data.$tenfile);
                            ?>
                            <br />
</p>
	  <img src='<?=PATH?>/media/images/products/<?=$tenfile?>' width=100 height=120 border="1" /><br />
                            <br />
                            <?
                        }
                    }
                }
                ?>
                <input type="hidden" name='anhsp' value='<?=$tenfile?>'/><?=$tenfile?>	  </td>
        </tr>
        <tr>
            <td align="center" valign="bottom" style="border-top:#FFFFFF"><img src="<?=PATH?>/media/images/products/<?=$pro->picture?>" width="100" height="120" border="1" /><br />&nbsp;</td>
        </tr>
        <tr>
            <td align="right">Gia&#769; sa&#777;n ph&acirc;&#777;m:</td>
            <td colspan="2" align="left"><input name="giasp" type="text" id="giasp" value="<?=$pro->price?>" /></td>
        </tr>
        <tr>
            <td align="right">S&ocirc;&#769; l&#432;&#417;&#803;ng: </td>
            <td colspan="2" align="left"><input name="soluongsp" type="text" id="soluongsp" value="<?=$pro->quantity?>"></td>
        </tr>
        <tr>
        <tr>
            <td align="right">Bảo hành: </td>
            <td colspan="2" align="left"><input name="baohanh" type="text" id="baohanh" value="<?=$pro->warranty?>"></td>
        </tr>
            <td align="right">Tra&#803;ng tha&#769;i sa&#777;n ph&acirc;&#777;m: </td>
            <td colspan="2" align="left">
                <?
                if($pro->status==1)
                {
                    ?>
                    <label><input type="radio" checked="checked" name="trangthaisp" value="1"> Hiện</label> <label><input type="radio" name="trangthaisp" value="0"> Ẩn</label>
                    <?
                }
                else
                {
                    ?>
                    <label><input type="radio" name="trangthaisp" value="1"> Hiện</label> <label><input type="radio" checked="checked" name="trangthaisp" value="0"> Ẩn</label>
                    <?
                }
                ?>	  </td>
        </tr>
        <tr>
            <td align="right" valign="middle">Mô tả sản phẩm </td>
            <td colspan="2" align="left"><label>
                <textarea name="motasp" id="motasp"><?=$pro->detail?></textarea>
            </label></td>
        </tr>
        <tr>
            <td align="right">Hãng sản xuất: </td>
            <td colspan="2" align="left">
                <select name="hangsx">
                    <option>--- Chọn hãng sản xuất ---</option>
                    <?
                    foreach($this->listmafa as $list=>$mafa)

                    {
                        if($mafa->mfid==$pro->mfid)
                        {
                            ?>
                            <option value="<?=$mafa->mfid?>" selected="selected"><?=$mafa->mfname?></option>
                            <?
                        }
                        else
                        {
                            ?>
                            <option value="<?=$mafa->mfid?>"><?=$mafa->mfname?></option>
                            <?
                        }
                    }
                    ?>
                </select>	  </td>
        </tr>
        <tr>
            <td align="right">Loại sản phẩm </td>
            <td colspan="2" align="left">
                <select name="loaisp">
                    <option>--- Chọn loại sản phẩm ---</option>
                    <?
                    foreach($this->listmenu as $list=>$menu)

                    {
                        if($menu->pfid==$pro->pfid)
                        {
                            ?>
                            <option value="<?=$menu->pfid?>" selected="selected"><?=$menu->pfname?></option>
                            <?
                        }
                        else
                        {
                            ?>
                            <option value="<?=$menu->pfid?>"><?=$menu->pfname?></option>
                            <?
                        }
                    }
                    ?>
                </select>	  </td>
        </tr>
        <tr>
            <td align="right">Nhà cung cấp: </td>
            <td colspan="2" align="left"><input type="text" name="nhacungcap" value="<?=$pro->distributor?>">
        </td>
        </tr>
        <tr>

            <td colspan="3" align="center" class="button"><label>
                <input type="submit" name="sua" value="S&#432;&#777;a" onclick="return fsanphamsua();">
                <input type="reset" name="Submit3" value="Làm lại" />
            </label>
                <label>
                    <input type="button" name="Submit2" value="Quay la&#803;i" onclick="location='/mymvc/administrator/product'">
                </label></td>
        </tr>
    </table>
</form>
    <?php }?>